<?if(!defined("PROLOG_INCLUDED") || PROLOG_INCLUDED!==true)die();?>
<?if(!empty($arResult["ITEMS"]) AND !empty($arParams["SHOW_FIELDS"])):?>
<?foreach($arResult["ITEMS"] as $arItem) {
	if(!empty($arItem["CATALOG_SECTION_ID"])) {
		$parentSecID = $arItem["CATALOG_SECTION_ID"];
		$rs = CatalogSection::GetByID($parentSecID);
		if ($arParent = $rs->GetNext()) {
			$parentID = $arParent["CATALOG_SECTION_ID"] === NULL ? 0 : $parentSecID;
		}
		$bShowUpBtn = true;
	}
}

	$arDecorate = Array(
		"NAME" => '<a href="/system/admin/catalog/elements.php?TYPE=#CATALOG_TYPE#&CATALOG_ID=#CATALOG_ID#&SECTION_ID=#ID#">#NAME#</a>',
	);
?>
<?elseif(!empty($arParams["SECTION_ID"]) AND $arParams["SECTION_ID"] != '0'):?>
<?$bShowUpBtn = true;$parentID = 0;?>
<?endif?>
<?if(isset($bShowUpBtn) && $bShowUpBtn):?>
	<span style="margin-left: 50px; border: 1px solid; border-color:#D8EBF5 #D8EBF5 #B9DBEE; padding: 3px 25px 3px 25px">
		<a href="/system/admin/catalog/elements.php?TYPE=<?=$arParams["CATALOG_TYPE"]?>&CATALOG_ID=<?=$arParams["CATALOG_ID"]?>&SECTION_ID=<?=$parentID?>">Вверх</a>
	</span>
<?endif;?>
	<table>
		<?if(isset($arParams["SHOW_FIELDS"]) && is_array($arParams["SHOW_FIELDS"]) && !empty($arParams["SHOW_FIELDS"])):?>
		<thead>
			<tr>
			<?foreach ($arParams["SHOW_FIELDS"] as $field):?>
				<th>
					<?=LANG('MODULE_CATALOG_ELEMENTS_'.$field)?>
				</th>
			<?endforeach?>
				<th>&nbsp;</th>
			</tr>
		</thead>
		<?endif?>
	<?if(!empty($arResult["ITEMS"]) && !empty($arParams["SHOW_FIELDS"])):?>
		<?foreach ($arResult["ITEMS"] as $n => $arItem):?>
			<tr <?=$n%2 ? 'class="altrow"' : ''?>>
				<?foreach ($arParams["SHOW_FIELDS"] as $field):?>
					<td>
						<?if (array_key_exists($field, $arDecorate)):?>
							<img src="<?=TPL_URL?>/images/folder.jpg" class="table-img" title="Раздел" />
							<?=GetStrTpl($arDecorate[$field], array_merge($arParams, $arItem))?>
						<?else:?>
							<?=$arItem[$field]?>
						<?endif?>
					</td>
				<?endforeach;?>
				<td><a href="?ACTION=EDIT&CATALOG_ID=<?=$arItem["CATALOG_ID"]?>&TYPE=<?=$arItem["CATALOG_TYPE_ID"]?>&ID=<?=$arItem["ID"]?>">Изменить</a> <a href="?ACTION=DELETE&ID=<?=$arItem["ID"]?>">Удалить</a></td>
			</tr>
		<?endforeach?>
<?endif?>